package main

import (
	"fmt"
	"strings"
)

func main() {
	s := make([]int, 3)
	fmt.Printf("s: %#v\n", s)

	for i, v := range s {
		fmt.Printf("%#v: %#v\n", i, v)
	}

	fmt.Printf("len: %#v\n", len(s))
	fmt.Printf("cap: %#v\n", cap(s))

	fmt.Println(strings.Repeat("*", 20))
	s = []int{0: 5, 1: 7, 2: -11}
	for i, v := range s {
		fmt.Printf("%#v, %#v\n", i, v)
	}

	fmt.Println(strings.Repeat("*", 20))
	s1 := s[1:3:3]
	fmt.Printf("s1: %#v\n", s1)

	s1[0] = 999
	fmt.Printf("s: %#v\n", s)
	fmt.Printf("s1: %#v\n", s1)

	// s1[3] = 777

	s1 = append(s1, 11111)
	fmt.Printf("s: %#v\n", s)
	fmt.Printf("s1: %#v\n", s1)

	s2 := s[1:3]
	//s2x := s[1:4]
	fmt.Printf("s2: %#v\n", s2)
	//fmt.Printf("s2x: %#v\n", s2x)

	s2 = append(s2, 9090)
	fmt.Printf("s: %#v\n", s)
	fmt.Printf("s2: %#v\n", s2)

	fmt.Println(strings.Repeat("*", 20))

	{
		s = make([]int, 0)
		fmt.Printf("s: %#v, addr: %p\n", s, &s)
		s = append(s, 789)
		fmt.Printf("s: %#v, addr: %p\n", s, &s[0])
	}
	{
		s = make([]int, 1)
		fmt.Printf("sa: %#v, addr: %p\n", s, &s[0])
		s = append(s, 789)
		fmt.Printf("sa: %#v, addr: %p\n", s, &s[0])
	}
	{
		s = make([]int, 1, 2)
		fmt.Printf("so: %#v, addr: %p\n", s, &s[0])
		s = append(s, 789)
		fmt.Printf("so: %#v, addr: %p\n", s, &s[0])
	}

	{
		var sss []int
		fmt.Printf("len(sss): %v\n", len(sss))
		// fmt.Printf("sss[0]: %v\n", sss[0]) //FIXME
	}
}
